package com.base.cn.platform.os.controller.order.order.utils;

import com.base.cn.platform.os.common.utils.FileExportImportUtil;
import com.base.cn.platform.os.common.utils.ObjectUtils;
import com.base.cn.platform.os.common.utils.StringUtils;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author zjh
 * @Description //TODO
 * @Date 2018/10/11 10:20
 */
public class OrderExportExcelUtils {

    /**
     *
     * @param data 表格数据
     * @param heads 表格头部
     * @param expName 表格名称
     * @param srcFile 文件列表容器
     * @throws Exception
     */
    public static void generateFile(List<List<String>> data,String [] heads,String expName,List<Map<String,Object>> srcFile) throws Exception {
        Map<String,Object> files = new HashMap<>();
        InputStream inputStream = FileExportImportUtil.createExcel(heads, data);
        files.put("name",expName);
        files.put("inputStream",inputStream);
        srcFile.add(files);

    }

    /**
     *支付类型
     * @param payType
     * @return
     */
    public static String  backPaymentType(String payType){
        //支付类型
        if(StringUtils.isNotEmpty(payType)){
            switch (payType){
                case "WEIXIN":
                    payType="微信";
                    break;
                case "ALIPAY":
                    payType="支付宝";
                    break;
                case "ACCOUNT":
                    payType="账户支付";
                    break;
                case "IOS":
                    payType="IOS内购";
                    break;
                case "FREE":
                    payType="免费";
                    break;
                case "COURSE_CART":
                    payType="课程卡";
                    break;
                case "MEMBER":
                    payType="会员";
                    break;
                case "GIVING":
                    payType="赠送";
                    break;
            }
        }else{
            payType ="";
        }

        return  payType;
    }


    /**
     *支付状态
     * @param orderStatus
     * @return
     */
    public static String  backOrderStatus(String orderStatus){
        //支付状态
        if(ObjectUtils.isNotEmpty(orderStatus)){
            switch (orderStatus){
                case "INIT":
                    orderStatus="未支付";
                    break;
                case "SUCCESS":
                    orderStatus="已支付";
                    break;
                case "REFUND":
                    orderStatus="已退款";
                    break;
                case "CANCEL":
                    orderStatus="已取消";
                    break;
                case "CLOSE":
                    orderStatus="已关闭";
                    break;
            }
        }else{
            orderStatus ="";
        }

        return  orderStatus;
    }

    /**
     *订单类型
     * @param orderType
     * @return
     */
    public static String  backOrderType(String orderType){

        if(StringUtils.isNotEmpty(orderType)) {
            switch (orderType) {
                case "COMMON":
                    orderType = "普通订单";
                    break;
                case "ACCOUNT":
                    orderType = "充值订单";
                    break;
            }
        }else{
            orderType ="";
        }
        return  orderType;
    }


    /**
     *订单来源
     * @param orderFrom
     * @return
     */
    public static String  backOrderFrom(String orderFrom){
        //支付状态
        if(ObjectUtils.isNotEmpty(orderFrom)){
            switch (orderFrom){
                case "WEB":
                    orderFrom="PC端";
                    break;
                case "APP":
                    orderFrom="APP端";
                    break;
                case "MOBILE":
                    orderFrom="H5端";
                    break;
                case "ADMIN":
                    orderFrom="后台";
                    break;
                case "COURSE_CART":
                    orderFrom="课程卡";
                    break;
                case "APPLY":
                    orderFrom="小程序";
                    break;
            }
        }else{
            orderFrom ="";
        }

        return  orderFrom;
    }

}
